import { fromJS } from 'immutable';
import * as actionTypes from './actionTypes'
const defaultState = fromJS({
    topicList: [],
    articleList: [],
    articlePage: 1,
    recommendList: [],
    showTop: false
})

export default (state = defaultState, action) => {
    switch (action.type) {
        case actionTypes.GET_HOME_DATA:
            return state.merge({
                topicList: fromJS(action.topicList),
                articleList: fromJS(action.articleList),
                recommendList: fromJS(action.recommendList)
            })
        case actionTypes.GET_ARTICLE_DATA:
            return state.merge({
                articleList: state.get('articleList').concat(action.list),
                articlePage: fromJS(action.page)
            })
        case actionTypes.TOGGLE_SCROLLTOP_SHOW:
            return state.set('showTop', action.show)
        default:
            return state
    }
}